From: Wei Gang Date: Wed, 9 Feb 2011 08:58:11 +0000 (+0000) Subject: x86: reduce magic number usage in XSAVE code X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10796 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=aa479ce9d1295d153db641ead0d174d9ef9fffa8;p=xen.git x86: reduce magic number usage in XSAVE code Signed-off-by: Wei Gang --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 51cde88e24..ec71dfcef3 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2223,7 +2223,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, if ( count == 0 && v->arch.xcr0 ) { /* reset EBX to default value first */ - *ebx = 576; + *ebx = XSAVE_AREA_MIN_SIZE; for ( sub_leaf = 2; sub_leaf < 64; sub_leaf++ ) { if ( !(v->arch.xcr0 & (1ULL << sub_leaf)) ) diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c index 0b052349e3..5c96da0456 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -221,7 +221,6 @@ static void restore_fpu(struct vcpu *v) } #define XSTATE_CPUID 0xd -#define XSAVE_AREA_MIN_SIZE (512 + 64) /* FP/SSE + XSAVE.HEADER */ /* * Maximum size (in byte) of the XSAVE/XRSTOR save area required by all diff --git a/xen/include/asm-x86/i387.h b/xen/include/asm-x86/i387.h index 9be8206b82..2cbbbc40e9 100644 --- a/xen/include/asm-x86/i387.h +++ b/xen/include/asm-x86/i387.h @@ -21,13 +21,14 @@ void xsave_init(void); int xsave_alloc_save_area(struct vcpu *v); void xsave_free_save_area(struct vcpu *v); +#define XSAVE_AREA_MIN_SIZE (512 + 64) /* FP/SSE + XSAVE.HEADER */ #define XSTATE_FP (1ULL << 0) #define XSTATE_SSE (1ULL << 1) #define XSTATE_YMM (1ULL << 2) #define XSTATE_LWP (1ULL << 62) /* AMD lightweight profiling */ #define XSTATE_FP_SSE (XSTATE_FP | XSTATE_SSE) #define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP) -#define XSTATE_YMM_OFFSET (512 + 64) +#define XSTATE_YMM_OFFSET XSAVE_AREA_MIN_SIZE #define XSTATE_YMM_SIZE 256 #define XSAVEOPT (1 << 0)